<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="extLibs" value="grid"/>
<sys:header title="福利发放统计" extLibs="${extLibs}" />
<div class="portlet box ${boxStyleColor}">
	<div class="portlet-title">
		<div class="caption"><i class="fa fa-coffee"></i> 福利发放统计</div>
		<div class="actions">
			<a href="#" class="btn btn-default btn-sm" id="btnSearch" title="查询"><i class="fa fa-search"></i> 查询</a>

			<a href="#" class="btn btn-default btn-sm" id="btnExport" title="导出"><i class="fa fa-external-link"></i>导出</a>
		</div>
	</div>
	<div class="portlet-body list">
		<form:form id="searchForm" modelAttribute="malWelfareDis" action="${ctx}/mal/malWelfareDis/listData" method="post" class="breadcrumb form-inline hide"
				data-page-no="${page.pageNo}" data-page-size="${page.pageSize}" data-order-by="${page.orderBy}">
			<div class="form-group">
				<label class="control-label">分工会：</label>
				<div class="input-inline" style="width: 180px">
					<sys:treeselect id="officeCode" name="office.officeCode" value="${malWelfareDis.office.officeCode}" labelName="officeName" labelValue="${malWelfareDis.officeName}"
									title="分工会" url="/sys/office/treeData?isAll=true" cssClass="required"  allowClear="true"/>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">节日：</label>
				<div class="input-inline">
					<form:select path="festivalId" multiple="false" cssClass="form-control" class="form-control  input-sm width-180" cssStyle="width:180px" onchange="">
						<option value=""> </option>
						<form:options items="${malFestivalWelfareList}"  itemLabel="festival" itemValue="id" htmlEscape="false"></form:options>
					</form:select>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label">套餐：</label>
				<div class="input-inline">
					<form:select path="setMealId" multiple="false" cssClass="form-control" class="form-control  input-sm width-180" cssStyle="width:180px" onchange="">
						<option value=""> </option>
						<form:options items="${malSetMealList}"  itemLabel="name" itemValue="id" htmlEscape="false"></form:options>
					</form:select>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label">会员：</label>
				<div class="input-inline">
					<form:input path="memberName" htmlEscape="false" maxlength="64" class="form-control input-sm width-160"/>
				</div>
			</div>
			<div class="form-group" style="margin-left:10px;"> 
				<input class="btn btn-primary btn-sm" type="submit" value="查询"/>&nbsp;
				<input class="btn default btn-sm" type="reset" value="重置" onclick="aaa()"/>
			</div>
		</form:form>
		<table id="dataGrid"></table>
	    <div id="dataGridPage"></div>
	</div>
</div>
<sys:footer extLibs="${extLibs}" />
<script type="text/javascript">
	// 初始化DataGrid对象
	$("#dataGrid").dataGrid({
		
		searchForm: $("#searchForm"), // 数据来源表单
		tabPageId: '${param.tabPageId}',// 当前页签编号
		
		// 设置数据表格列
		columnModel: [
			{header:'会员', name:'memberName', index:'a.memberName', width:100, align:"left"},
			{header:'工号', name:'memberCode', index:'a.memberCode', width:100, align:"left"},
			{header:'所在校区', name:'campus', index:'a.campus', width:100, align:"left"},
			{header:'单位', name:'officeName', index:'a.officeName', width:100, align:"left"},
			{header:'领取地点', name:'place', index:'a.place', width:100, align:"left"},
			{header:'节日', name:'festivalTitle', index:'a.festival_title', width:300, align:"left", frozen:true, formatter: function(val, obj, row, act){
				return '<a href="${ctx}/mal/malWelfareDis/form?id='+row.id+'" class="btnList" data-title="编辑福利发放">'+(val ? val : row.id)+'</a>';
			}},
			{header:'套餐名称', name:'setMealName', index:'a.set_meal_name', width:200, align:"left"},
			{header:'操作时间', name:'updateDate', index:'a.update_date', width:150, align:"center"},
			{header:'操作', name:'actions', width:100, fixed:true, sortable:false, formatter: function(val, obj, row, act){
				var actions = [];//<shiro:hasPermission name="mal:malWelfareDis:edit">
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/mal/malWelfareDis/form?id='+row.id+'" class="btnList" title="编辑福利发放"><i class="fa fa-pencil"></i></a>&nbsp;');
					actions.push('<a href="${ctx}/mal/malWelfareDis/delete?id='+row.id+'" class="btnList" title="删除该福利发放" data-confirm="确认要删除该福利发放吗？"><i class="fa fa-trash-o"></i></a>&nbsp;');
				}//</shiro:hasPermission>
				return actions.join('');
			}}
		],
		ajaxSuccess: function(data){ // 加载成功后执行方法
			
		}
	});



	//数据导出
	$("#btnExport").click(function(){
		top.$.jBox.confirm("确认要导出数据吗？","系统提示",function(v,h,f){
			if(v=="ok"){
				ajaxDownload('${ctx}/mal/malWelfareDis/export',$("#searchForm").serialize());
			}
		},{buttonsFocus:1});
		top.$('.jbox-body .jbox-icon').css('top','55px');
	});

	/**
	 * Ajax 文件下载
	 */
	function ajaxDownload(url, data, method) {
		// 获取url和data
		if (url && data) {
			// data 是 string 或者 array/object
			data = typeof data == 'string' ? data : jQuery.param(data);
			// 把参数组装成 form的 input
			var inputs = '';
			$.each(data.split('&'), function() {
				var pair = this.split('=');
				inputs += '<input type="hidden" name="' + pair[0] + '" value="'
						+ pair[1] + '" />';
			});
			// request发送请求
			$('<form action="' + url + '" method="' + (method || 'post')
					+ '" >' + inputs + '</form>').appendTo('body').submit().remove();
		}
	}
	function aaa() {
		$("#officeCodeCode").val("");
	}

</script>